

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import sun.swing.StringUIClientPropertyKey;


/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/27 8:50
 * @description:
 */
public class task5_11_2 {

  public static void main(String[] args) {
    HashMap<String,Student> stringStudentHashMap=new HashMap<String,Student>();
    Student xs=new Student("张三",18);
    Student is=new Student("里斯",20);
    Student ww=new Student("王五",17);
    stringStudentHashMap.put("s1",xs);
    stringStudentHashMap.put("s2",is);
    stringStudentHashMap.put("s3",ww);

    Iterator iterator=stringStudentHashMap.keySet().iterator();
    while (iterator.hasNext()){
      String key= (String) iterator.next();
      Student student=stringStudentHashMap.get(key);

      System.out.println(key+"："+student);
    }
    System.out.println();
    Iterator entryIterator= stringStudentHashMap.entrySet().iterator();
    while (entryIterator.hasNext()){
      Map.Entry<String,Student>entry= (Entry<String, Student>) entryIterator.next();
    String key=entry.getKey();
    Student value=entry.getValue();
      System.out.println(key+"--"+value);
    }
  }

}
